﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace Smtp_server
{
    class Daemon
    {
     
        private Thread thread;
        private Daemon_smtp daemon_smtp;
        private bool active;

        public Daemon(ILogger ilogger,DBagent dbagent) 
        {
            daemon_smtp = new Daemon_smtp(ilogger,dbagent);
            this.active = false;  
        }

        public void Start() 
        {
            if (this.active == true)
                return;
            this.active = true;
            thread = new Thread(new ThreadStart(this.daemon_smtp.Start));
            thread.Start();
        }
        public void Stop()
        {
            if (this.active == false)
                return;
            this.active = false;
            this.daemon_smtp.Stop();
            thread.Abort();
        }

        
    }
}
